﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminMaster.master" AutoEventWireup="true"
    Inherits="GroupManagement" CodeBehind="GroupManagement.aspx.cs" %>

<%@ Register Assembly="AjaxControlLib" Namespace="AjaxControlLib" TagPrefix="ajaxcontrollib" %>
<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        $(function () {
            HideAddNew();
        });
        function ShowAddNew() {
            $("#divAddNew").show();
            return false;
        }
        function HideAddNew() {
            $("#divAddNew").hide();
            return false;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div id="content1">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td class="GroupHeader" style="height: 18px; text-align: left;" colspan="4" valign="top">
                     Group List
                </td>
            </tr>
            <tr style="height: 30px">
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:UpdatePanel ID="updPnlGroupList" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <asp:GridView ID="gvGroupList" Width="100%" runat="server" AutoGenerateColumns="False"
                                EnableModelValidation="True" DataKeyNames="GroupID" OnRowDeleting="gvGroupList_RowDeleting"
                                OnRowCommand="gvGroupList_RowCommand" PageSize="5" AllowPaging="true">
                                <Columns>
                                    <asp:BoundField DataField="Name" HeaderText="Name" />
                                    <asp:BoundField DataField="Description" HeaderText="Description" />
                                    <asp:BoundField DataField="ContactLevel" HeaderText="Contact Level" />
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="edit" runat="server" CommandName="EditGroup" CausesValidation="false">Edit</asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:CommandField ShowDeleteButton="True" />
                                </Columns>
                            </asp:GridView>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="click" />
                        </Triggers>
                    </asp:UpdatePanel>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Button ID="btnAddNew" runat="server" Text="Add New" OnClientClick="ShowAddNew()"
                        OnClick="btnClear_Click" CausesValidation="false" />
                </td>
            </tr>
        </table>
    </div>
    <asp:UpdatePanel ID="updPnlAddNewGroup" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div id="divAddNew">
                <fieldset>
                    <table width="100%" cellspacing="0" cellpadding="0">
                        <tr align="left">
                            <td colspan="2">
                                <asp:ValidationSummary ID="valSummaryAddNew" runat="server" ValidationGroup="vgAddNew" />
                                <asp:Label ID="lblErrorAddNew" runat="server" CssClass="error"></asp:Label>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Name
                            </td>
                            <td colspan="2">
                                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rqdValName" runat="server" SetFocusOnError="true"
                                    ValidationGroup="vgAddNew" ErrorMessage="The name field is required" ControlToValidate="txtName"
                                    Display="None"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Description
                            </td>
                            <td width="35%">
                                <asp:TextBox ID="txtDescription" TextMode="MultiLine" Rows="10" Columns="25" runat="server"></asp:TextBox>
                            </td>
                            <td rowspan="2" width="50%">
                                <fieldset>
                                    <legend>Assign Employee </legend>
                                    <table width="100%">
                                        <tr>
                                            <td width="15%">
                                                <asp:Panel ID="pnlEmployeeLookUp" runat="server">
                                                    <ajaxcontrollib:EmployeeLookup ID="empLookUp" runat="server" AutoSearch="false" Enabled1="True"
                                                        NameFieldWidth="175" InstanceID="0" Label="" MaxResults="0" Population="WholeFirmActive"
                                                        SearchStringMinimum="1" SecurityGroupID="0" />
                                                </asp:Panel>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnAddUsers" Text="Add" runat="server" OnClick="btnAddUsers_Click"
                                                    CausesValidation="false" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:ListBox ID="lstAssignedUsers" runat="server" SelectionMode="Multiple" Width="223px">
                                                </asp:ListBox>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnRemoveUsers" runat="server" Text="Remove" CausesValidation="false"
                                                    OnClick="btnRemoveUsers_Click" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <asp:Label ID="lblUserList" runat="server" CssClass="error"> </asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </td>
                        </tr>
                        <tr align="left" style="height: 30px">
                            <td width="15%">
                                Contact Level
                            </td>
                            <td>
                                <asp:TextBox ID="txtContactLevel" runat="server"></asp:TextBox>
                                <asp:RegularExpressionValidator ID="regExpValContactLevel" runat="server" ControlToValidate="txtContactLevel"
                                    ValidationGroup="vgAddNew" ErrorMessage="The contact level is invalid" ValidationExpression="^\d+$"
                                    Display="None" SetFocusOnError="True"></asp:RegularExpressionValidator>
                            </td>
                        </tr>
                        <tr style="height: 30px">
                            <td colspan="2" align="center">
                                <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" ValidationGroup="vgAddNew" />
                                <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false"
                                    OnClientClick="javascript: return HideAddNew()" OnClick="btnClear_Click" />
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAddNew" EventName="click" />
            <asp:AsyncPostBackTrigger ControlID="gvGroupList" EventName="rowcommand" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
